package cn.acmoj.oj.controller;

import cn.acmoj.oj.service.ImagesService;
import cn.acmoj.oj.service.NewsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

/**
 * cn.acmoj.oj.controller
 * Springer
 * 2017-11-22
 */
@Controller
public class IndexController {

    @Resource
    private NewsService newsService;
    @Resource
    private ImagesService imagesService;

    @RequestMapping(value = "index", method = RequestMethod.GET)
    public String index(HttpServletRequest request) {
        ServletContext servletContext = request.getServletContext();
        request.setAttribute("news", newsService.getAll());
        request.setAttribute("images", imagesService.getAll());
        servletContext.setAttribute("ojName", "我的五毛测评");
        return "index";
    }

    @RequestMapping(value = "foot", method = RequestMethod.GET)
    public String foot() {
        return "include/foot";
    }

    @RequestMapping(value = "heard", method = RequestMethod.GET)
    public String heard() {
        return "include/heard";
    }
}
